round to two decimal places python

36

round to two decimal places python -

>>> x = 13.949999999999999999
>>> x
13.95
>>> g = float("{0:.2f}".format(x))
>>> g
13.95
>>> x == g
True
>>> h = round(x, 2)
>>> h
13.95
>>> x == h
True

round off float to 2 decimal places in python -

answer = str(round(answer, 2))

Comments

Submit
0 Comments